﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace InternshipManagement.Models
{
    public class FormRepository
    {
        public InternshipEntities entities = new InternshipEntities();

        #region ApplicationForm

        public ApplicationForm GetApplicationForm(int UserID,int CourseID)
        {
            return entities.ApplicationForms.FirstOrDefault(f => f.UserID == UserID && f.CourseID == CourseID);
        }
        public bool ApplicationFormExists(int UserID, int CourseID)
        {
            return entities.ApplicationForms.FirstOrDefault(f => f.UserID == UserID && f.CourseID == CourseID) != null;
        }

        public void AddApplicationForm(ApplicationForm form)
        {
            entities.ApplicationForms.AddObject(form);
        }
        public void DeleteApplicationForm(ApplicationForm form)
        {
            entities.ApplicationForms.DeleteObject(form);
        }

        #endregion


        //
        // Persistence
        public void Save()
        {
            entities.SaveChanges();
        }
    }
}